//
//  SPStorePlanCreate.swift
//  StorePlan
//
//  Created by admin on 2020/9/4.
//  Copyright © 2020 admin. All rights reserved.
//

import SwiftUI
import RealmSwift

struct SPStorePlanCreate: View {
    @Environment(\.presentationMode) var presentationMode: Binding<PresentationMode>
    
    @State var pid = UUID().uuidString
    @State var price:String = ""
    @State var num:String = ""
    
    
    func insterOrupdata()  {
        let storeDataItem = StoreDataItem()
        storeDataItem.parment = pid
        storeDataItem.price = price
        storeDataItem.ccount = num
        storeDataItem.ug_add()
    }
    var body: some View {
        VStack {
            
            InputView(title: "价格：", plstr: "请输入价格", value: $price)
            InputView(title: "数量:", plstr: "请输入数量", value: $num)
  
            Button(action: {
                self.insterOrupdata()
                self.presentationMode.wrappedValue.dismiss()
            }) {
                
                Text("保存")
                    .foregroundColor(Color.white)
            }
            .frame(width: 320.0, height:44)
            .background(Color.red)
            .cornerRadius(8)
            .padding(8)
            
            Spacer()
        }
        .padding()
        .background(Color.init(red: 0.9, green: 0.9, blue: 0.9))
        .navigationBarTitle(Text("新增"))
        
    }
    
}

struct SPStorePlanCreate_Previews: PreviewProvider {
    static var previews: some View {
        SPStorePlanCreate()
    }
}
